﻿using System;
using System.Runtime.InteropServices;
using Microsoft.MediaPlayer.Interop;

namespace BMproductions.Media.MediaPlayer.WMPPlus {
	public abstract class WMPPlusPublic: WMPPlusBase, IWMPPlusHook {
		public const string WMPPlusHookName = "WMPPlusHook.dll";

		//WMPPlusCore core
		protected string currentFolder;
		protected IWMPMedia currentMedia;

		public virtual string CurrentFolder { get { return this.currentFolder; } }
		public virtual IWMPMedia CurrentMedia { get { return this.currentMedia; } }

		void IWMPPlusHook.Initialize3(IntPtr module, IntPtr instance, int majorVersion, int minorVersion, ImportLibrary lib) {
			WMPPlusCore.Hook.Initialize3(module, instance, majorVersion, minorVersion, lib);
		}

		void IWMPPlusHook.Uninitialize() {
			WMPPlusCore.Dispose();
		}

		void IWMPPlusHook.CreatePlugin(ref Guid clsid, IntPtr plugin, IWMPPluginUI intf) {
			WMPPlusCore.Plugins.WrapPlugin(clsid, plugin, intf);
		}

		void IWMPPlusHook.SetupPlugin(ref Guid clsid, bool shutdown) {
			WMPPlusCore.Plugins.SetupPlugin(clsid, shutdown);
		}

		int IWMPPlusHook.PlaceSubMenu(IntPtr menu, IntPtr hMenu) {
			if (WMPPlus.Plugin == null)
				return -1;
			return WMPPlus.Plugin.Menu.PlaceSubMenu(menu, hMenu);
		}

		void IWMPPlusHook.InvokeSubMenu(IntPtr menu, IntPtr hMenu) {
			if (WMPPlus.Plugin != null)
				WMPPlus.Plugin.Menu.InvokeSubMenu(menu, hMenu);
		}

		void IWMPPlusHook.InvokeMenuItem(IntPtr item, IntPtr hWnd) {
			if (WMPPlus.Plugin != null)
				WMPPlus.Plugin.Menu.InvokeMenuItem(item, hWnd);
		}
	}
}
